import { Component, OnInit, ViewEncapsulation, ViewChild } from '@angular/core';
import { ApiService } from 'src/app/core/api';
import { ActivatedRoute, Router } from '@angular/router';
import { SwiperComponent, RatingConfig } from 'ngx-weui';
import { StorageService } from 'src/app/core/sotrage/storage.service';

@Component({
	selector: 'app-Agency',
	templateUrl: './index.component.html',
	styleUrls: ['./index.component.less'],
	encapsulation: ViewEncapsulation.None,
})
export class AgencyComponent implements OnInit {
	@ViewChild('swiper', { static: true }) swiper: SwiperComponent;
	lang = this.sto.get('lang')?this.sto.get('lang'):'zh';
	del;
	levelStar=0;
	imgs: Array<any>;
	options: any = {
		init: true,
		direction:'vertical',
		observer: true,
		slideShadows: false,
	};
	customIconsAndClassCog: RatingConfig = {
		max:5,
		stateOff: 'off',
		stateOn: 'on',
		cls: 'rating'
	};

	constructor(
		private activedRoute: ActivatedRoute,
		private sto: StorageService,
		private api: ApiService,
		private router: Router
	) {
		this.getDel({ id: this.activedRoute.snapshot.queryParams.id })
	}

	getDel(data) {
		this.api.post('游戏详情', data).then(res => {
			this.del = res['data']['game'];
			this.levelStar = this.del.levelStar;
			this.imgs = this.del['images'].split(',');
		}).catch(res => {
			return res;
		});
	}

	ngOnInit() {

	}

	onSel(teg) {
		this.api.post('开始游戏', {id:teg.id}).then(res => {
			this.router.navigate(['/gz'], {
				queryParams: res['data']
			});
			console.log('获取相关提供商信息以及余额===',res)
		})
	}
	back() { history.back(); }
}
